<?php 

include(dirname(__FILE__).'/../../bootstrap/Doctrine.php');

function create_job($category)
{
  if (is_null($category))
  {
    $category = Doctrine::getTable('JobeetCategory')
      ->createQuery()
      ->limit(1)
      ->fetchOne();
  }
 
  $job = new JobeetJob();
  $job->fromArray(array(
    'category_id'  => $category->getId(),
    'company'      => 'Sensio Labs',
    'position'     => 'Senior Tester',
    'location'     => 'Paris, France',
    'description'  => 'Testing is fun',
    'how_to_apply' => 'Send e-Mail',
    'email'        => 'job@example.com',
    'token'        => rand(1111, 9999),
    'is_activated' => true,
  ));
 
  $job->save();
}


$t = new lime_test(1);


// TEST su count active jobs

$t->comment('->countActiveJobs()');


$category = Doctrine::getTable('JobeetCategory')->createQuery()->fetchOne();

create_job($category);
create_job($category);
create_job($category);
create_job($category);
create_job($category);

$t->is($category->countActiveJobs(), 6, '->countActiveJobs() return the number of active Jobs for a Category');
